import { Controller, Get, Post,Put, Body, Patch,Query, Param, Delete } from '@nestjs/common';
import { UserInfoService } from './userinfo.service';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import {UserInfoDto} from './dto/userinfo.dto'
import { isNoAuth } from 'src/utils/decorator/jwt.decorator';
@ApiTags('用户管理')
@Controller('userInfo')
@isNoAuth()
export class UserInfoController {
  constructor(private readonly userInfoService: UserInfoService) {}

  @Post("add")
  create(@Body() userInfoDto: UserInfoDto) {
    return this.userInfoService.create(userInfoDto);
  }

  @Get("list")
  findAll() {
    return this.userInfoService.findAll();
  }

  @Get("search")
  async findOne(@Query() query):Promise<UserInfoDto[]> {
    return  await this.userInfoService.findOne(query.account, query.id);
  }

  @Put('update/:id')
  update(@Param() param, @Body() userInfoDto: UserInfoDto) {
    return this.userInfoService.update(param.id, userInfoDto);
  }

  @Delete('del')
  remove(@Query() query):Promise<string> {
    return this.userInfoService.remove(query.id);
  }
}
